package algorithms.sort;

import java.util.Arrays;

public class BubbleSorter {
	public static void sort(int[] array) {
		for(int i = 0; i < array.length - 1; i ++) {
			for(int j = 0; j < array.length - i - 1; j ++) {
				if(array[j + 1] < array[j])
					swap(array, j + 1, j);
			}
		}
	}
	
	private static void swap(int[] array, int front, int back) {
		int temp = array[front];
		array[front] = array[back];
		array[back] = temp;
	}
	
	public static void main(String[] args) {
		int[] array = new int[] {2,4,71,13,6,4,21,2, 8, 5};
		sort(array);
		System.out.println(Arrays.toString(array));
	}
}
